<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>postMessage</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }
    </style>
</head>
<body>

    <iframe src="http://127.0.0.1:8080/c.html" frameborder="0" class="ifr"></iframe>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(".ifr").on("load", function (){
            // console.log(this.contentWindow);
            // postMessage 跨域window也可以使用该方法
            // postMessage(message, targinOrigin)
            this.contentWindow.postMessage("发送给C页面的内容", "http://127.0.0.1:8080");
        })

        window.onmessage = function (e){
            console.log("POST页面接受：", e.data);
        }
    </script>
</body>
</html>